package com.diudiutechnology.www.yadiudiu.yadiudiu.mine.MyActivity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.diudiutechnology.www.yadiudiu.yadiudiu.mine.MyAdapter.MyOrderActivityAdapter;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.BuyACarFragmentModel;
import com.diudiutechnology.www.yadiudiu.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/8/18.
 * 我的订单
 */

public class MyOrderActivity extends Activity implements View.OnClickListener {
    Context context;
    @Bind(R.id.my_order_list)
    ListView myOrderList;
    private List<BuyACarFragmentModel> houselist;
    MyOrderActivityAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_order);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        context = this;
        adapter=new MyOrderActivityAdapter(this);
        myOrderList.setAdapter(adapter);
        initData();
    }
    //数据
    private void initData() {
        houselist = new ArrayList<>();
        houselist.clear();
        BuyACarFragmentModel model = new BuyACarFragmentModel();
        model.setName("订单号：20170810321652");
        model.setLet("一个双门小冰箱，50斤左右。");
        model.setMoney1("");
        model.setDistance("2017-8-17");
        model.setPraise("0");
        model.setDate("苦力");
        houselist.add(model);

        model = new BuyACarFragmentModel();
        model.setName("订单号：20170810321256");
        model.setLet("GS8 2017款 320T 两驱精英版");
        model.setMoney1("");
        model.setDistance("2017-8-16");
        model.setPraise("1");
        model.setDate("购车");
        houselist.add(model);

        model = new BuyACarFragmentModel();
        model.setName("订单号：20170805321256");
        model.setLet("渝北 万科朗润园 精装单间 家电齐全 拎包入住");
        model.setMoney1("¥：1.00元");
        model.setDistance("2017-8-16");
        model.setPraise("2");
        model.setDate("租房");
        houselist.add(model);

        model = new BuyACarFragmentModel();
        model.setName("订单号：20170804345356");
        model.setLet("渝北 万科朗润园 精装单间 家电齐全 拎包入住");
        model.setMoney1("¥：1.00元");
        model.setDistance("2017-8-15");
        model.setPraise("3");
        model.setDate("出租房");
        houselist.add(model);

        model = new BuyACarFragmentModel();
        model.setName("订单号：20170804345356");
        model.setLet("一份文件");
        model.setMoney1("");
        model.setDistance("2017-8-13");
        model.setPraise("4");
        model.setDate("快递");
        houselist.add(model);
        adapter.addItem(houselist);
        myOrderList.setOnItemClickListener(clickListener);
    }
    AdapterView.OnItemClickListener clickListener=new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            startActivity(new Intent(context,TheOrderDetailsActivity.class));
        }
    };



    //评论
    public void processCommentaries(){
      startActivity(new Intent(context,CommentariesActivity.class));
    }
    @Override
    public void onClick(View view) {

    }
}
